<template>
  <view class="user-userinfo-page">
    <!--头像和昵称-->
    <view class="icon-and-nickname">
      <image :src= "userInfo.userInfo.avatarUrl" class="avatar"></image>
      <view class="nickname">{{userInfo.userInfo.nickName}}</view>
    </view>
    
    <!--面板-->
    <view class="user-panel">
      <!--收藏關注相關-->
      <view class="my-info-panel">
        <view class="panel-body">
          <view class="panel-items">
            <text>8</text>
            <text>收藏的農村</text>
          </view>
          <view class="panel-items">
            <text>12</text>
            <text>我的收藏</text>
          </view>
          <view class="panel-items">
            <text>8</text>
            <text>我的關注</text>
          </view>
          <view class="panel-items">
            <text>8</text>
            <text>歷史記錄</text>
          </view>
        </view>
      </view>
      <!--货品相關-->
      <view class="shop-relate-panel">
        <view class="panel-title">
          我的訂單
        </view>
        <view class="panel-body">
          <view class="panel-item">
            <image src="/static/tab_bar_icon/wait-for-parchase.png" class="icon"></image>
            <text>待付款</text>
          </view>
          <view class="panel-item">
            <image src="/static/tab_bar_icon/wait-for-delivery.png" class="icon"></image>
            <text>待收货</text>
          </view>
          <view class="panel-item">
            <image src="/static/tab_bar_icon/refund.png" class="icon"></image>
            <text>退货</text>
          </view>
          <view class="panel-item">
            <image src="/static/tab_bar_icon/all-order.png" class="icon"></image>
            <text>全部訂单</text>
          </view>
        </view>
        
      </view>
      <!--設定與賣家相關-->
      <view class="config-panel">
        <view class="panel-list-item">
          <text>卖家系统</text>
          <uni-icons type="arrowright" size = "15"></uni-icons>
        </view>
        <view class="panel-list-item">
          <text>收货地址</text>
          <uni-icons type="arrowright" size = "15"></uni-icons>
        </view>
        <view class="panel-list-item">
          <text>我的资料</text>
          <uni-icons type="arrowright" size = "15"></uni-icons>
        </view>
        <view class="panel-list-item">
          <text>联系客服</text>
          <uni-icons type="arrowright" size = "15" ></uni-icons>
        </view>
        <view class="panel-list-item" @click="logout">
          <text>退出登錄</text>
          <uni-icons type="arrowright" size = "15"></uni-icons>
        </view>
        
      </view>
    </view>
    
  </view>
</template>

<script>
  import {mapState, mapMutations} from 'vuex'
  export default {
    
    name:"userInfoPage",
    data() {
      return {
        
      };
    },
    methods:{
      ...mapMutations('user', ['updateAddress','updateUserInformation', 'updateToken']),
      //退出登錄時清空所有资料
      async logout(){
        const[err, succ] = await uni.showModal({
          title: '确認登出',
          content:'确定退出登入?'
        }).catch(err => err)
      
        if(succ && succ.confirm){
          this.updateAddress({})
          this.updateUserInformation({})
          this.updateToken('')
        }
      }

    },
    computed:{
      ...mapState('user', ['userInfo'])
    }
  }
</script>

<style lang="less">
  .user-userinfo-page{
    height: 100%;
    background-color: #F4F4F4;
    .icon-and-nickname{
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      height: 430rpx;
      background-color: #18BC37;
      .avatar{
        width: 100px;
        height: 100px;
        border-radius: 25px;
        border: 2px solid #FFF;
        box-shadow: 0, 3px 5px gray;
        
      }
      .nickname{
        font-size: 18px;
        color: #000000;
        font-weight: bold;
        margin-top: 10px;
      }
    }
    .user-panel{
      padding: 0 10px;
      position: relative;
      top: -10px;
      .my-info-panel{
        background-color: white;
        border-radius: 3px;
        margin-bottom: 10px;
        .panel-body{
          display: flex;
          justify-content: space-around;
          .panel-items{
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
            padding: 10px 0;
            font-size:12px;
          }
        }
        
      }
      .shop-relate-panel{
        padding: 0 10px;
        background-color: white;
        border-radius: 3px;
        margin-bottom: 10px;
        .panel-title{
          line-height: 45px;
          padding-left: 10px;
          font-size: 14px;
          border-bottom: 1px solid #F4F4F4;
        }
        .panel-body{
          display: flex;
          justify-content: space-around;
          font-size: 12px;
          .panel-item{
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
            padding: 10px 0;
            .icon{
              width: 35px;
              height: 35px;
            }
          }
        }
      }
      .config-panel{
        padding: 0 10px;
        background-color: white;
        border-radius: 3px;
        margin-bottom: 10px;
        .panel-list-item{
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 14px;
          padding: 0 10px;
          line-height: 45px;
        }
      }
    }
  }

</style>
